﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;


//根据官方Guide创建
namespace MEF_First_Touch
{

    public class Program
    {
        [Import]
        IStudy Study { get; set; }

        static void Main(string[] args)
        {
            //实例化类
            Program p = new Program();
            p.Run();
            Console.ReadKey();
        }

        /// <summary>
        /// 调用创建容器
        /// </summary>
        public void Run()
        {
            //利用目录添加到容器
            var catalog = new AssemblyCatalog(typeof(Program).Assembly);
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);

            Study.Study();
        }

    }

}
